#Requires AutoHotkey v2.0

main

main(){
    ; GUI 创建和事件绑定
    ; global edit1
    g1 := Gui("+AlwaysOnTop", "IP信息查看器")
    global edit1 := g1.Add("Edit", "w400 h300 VScroll", "")
    bt1 := g1.Add("Button", "w100 h30", "获取IP")
    bt1.OnEvent("Click", GetIP)
    g1.Show()
    WinActivate(g1)
}

; 函数定义
GetIP(*) {
    global edit1
    res := RunCmd("ipconfig")
    edit1.Value := res
}

RunCmd(command) {
    shell := ComObject("WScript.Shell")
    exec := shell.Exec(A_ComSpec " /c " command)
    result := exec.StdOut.ReadAll()
    return result
}